package com.sec.android.app.myfiles.launch;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;

import com.sec.android.app.myfiles.activity.GetMoreSpaceActivity;
import com.sec.android.app.myfiles.info.AppConstants;
import com.sec.android.app.myfiles.log.SamsungAnalyticsLog;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.module.optimizestorage.OptimizeStorageFileRecord;
import com.sec.android.app.myfiles.navigation.NavigationInfo;
import com.sec.android.app.myfiles.navigation.NavigationManager;

/**
 * Created by eungho78.lee on 2016-11-08.
 */
public class HandleRunOptimizeStorageImp extends AbsHandleLaunchImp {

    @Override
    public boolean isMyJob(Intent intent) {
        final String action = intent.getAction();
        String componentClassName = null;
        ComponentName component = intent.getComponent();
        if (component != null) {
            componentClassName = component.getClassName();
        }
        return AppConstants.Action.RUN_OPTIMIZE_STORAGE.equals(action) ||
                GetMoreSpaceActivity.class.getName().equals(componentClassName);
    }

    @Override
    public boolean _handleStart(int processId, Activity activity, Intent intent) {
        FileRecord record = FileRecord.createFileRecord(FileRecord.StorageType.OptimizeStorage,
                OptimizeStorageFileRecord.getOptimizeStoragePath(FileRecord.OptimizeStorageType.Overview));
        if (record != null) {
            NavigationInfo navigationInfo = NavigationInfo.getInstance(NavigationInfo.NavigationMode.Normal, record);
            navigationInfo.setScreenPath(SamsungAnalyticsLog.ScreenPath.GET_MORE_SPACE);
            NavigationManager.getInstance(processId).enter(navigationInfo);
        }
        return true;
    }
}